<?php
/**
 * View  LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    17-mag-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript">
    //<![CDATA[
    function selectable(){
	$('tr[class~="selectable"]').click(function(){
	    var id = $(this).attr('id');
	    
	    //$(this).siblings().removeClass('selected');
	    $(this).addClass('selected');
	    $("input#event_check_"+ id.substr(6,id.length)).attr('checked', true);
	    
	    unselectable();
	});
    };
    
    function unselectable(){
	$('tr[class~="selected"]').click(function(){
	    var id = $(this).attr('id');
	    
	    $(this).removeClass('selected');
	    $("input#event_check_"+ id.substr(6,id.length)).attr('checked', false);
	    
	    selectable();
	})
    };
     
    $(document).ready(function()
    {
        var paginator =	$('#events-list').pagination({
	    'targetUrl' : '/admin/ajax/select/events',
	    'orderField' : 'event_title',
	    'orderDir' : 'asc',
	    'selected' : '<?php echo( !empty( $this->data['events'] ) ? implode( ':', array_keys( $this->data['events'] ) ) : '') ?>'
	    },selectable // CallBack
	);
    });

    //]]>
</script>
<form id="form-invia" class="fab" method="post" action="/admin/live/rassegne/id/<?php echo $this->live_id ?>">
    <div id="content">
	<div id="summary" class="live">
	    <div class="head live">
		<h2>Live:</h2>
	    </div>
	    <div class="body">
		<table cellspacing="0" class="table">
		    <tbody>
			<tr>
			    <th>Artista/i:</th>
			    <td>
				<strong>
				    <?php
				    foreach( $this->data['artists']['main'] as $artist ) :
					$artists_list .= $artist['artist_name'] . ', ';
				    endforeach;
				    ?>
				    <?php echo substr( $artists_list, 0, -2 ); ?>
				</strong>
			    </td>
			</tr>
			<?php if( count( $this->data['artists']['openingact'] ) ): ?>
    			<tr>
    			    <th>Opening-act:</th>
    			    <td>
    				<strong>
					<?php
					$artists_list = null;
					foreach( $this->data['artists']['openingact'] as $artist ) :
					    $artists_list .= $artist['artist_name'] . ', ';
					endforeach;
					?>
					<?php echo substr( $artists_list, 0, -2 ); ?>				
    				</strong>
    			    </td>
    			</tr>			
			<?php endif; ?>
			<tr>
			    <th>Location:</th>
			    <td><strong><?php echo $this->location['location_name'] ?>, <?php echo $this->location['location_city'] ?> (<?php echo $this->province[$this->location['location_province_id']]['province_short_name'] ?>)</strong></td>
			</tr>
			<tr>
			    <th>Quando:</th>
			    <td><strong><?php echo $this->data['start_day'] ?> <?php echo $this->data['day'] ?>-<?php echo $this->data['month'] ?>-<?php echo $this->data['year'] ?></strong> alle <strong><?php echo $this->data['live_start_time_h'] ?>h<?php echo $this->data['live_start_time_m'] ?></strong></td>
			</tr>
			<tr class="break">
			    <td colspan="2">&nbsp;</td>
			</tr>
			<tr>
			    <th>Ingresso:</th>
			    <td><?php echo $this->data['live_price_1'] ? $this->data['live_price_1'] . ',' . $this->data['live_price_2'] . ' &euro;' : 'gratuito' ?></td>
			</tr>
			<tr>
			    <th>Apertura Cancelli:</th>
			    <td><?php echo $this->data['live_gate_open_h'] ? $this->data['live_gate_open_h'] . 'h' . $this->data['live_gate_open_m'] : '' ?></td>
			</tr>
			<tr>
			    <th>Note:</th>
			    <td><?php echo $this->data['live_notes'] ?></td>
			</tr>
		    </tbody>
		</table>
	    </div>
	</div>
	<br style="clear: both" />

	<ul>
	    <li class="section first">
		<h3>Associa Live a Rassegna</h3>
		<div><strong>Clicca</strong> per selezionare la rassegna a cui vuoi associare il live.<br />
		    <strong>Clicca di nuovo</strong> per deselezionare</div>
	    </li>
	</ul>
	<table class="log clearfix list">
	    <tbody id="events-list">
		<tr class="selectable">
		    <th>th</th>
		    <td class="title">td</td>
		    <td>td</td>
		    <td title="Selezionata" class="status">&nbsp;</td>
		</tr>
		<tr class="selectable">
		    <th>th</th>
		    <td class="title">td</td>
		    <td>td</td>
		    <td title="Selezionata" class="status">&nbsp;</td>
		</tr>
	    </tbody>
	</table>

    </div>
    <input type="hidden" name="conferma" id="conferma" value="conferma" />
    <input type="hidden" name="event_id" id="event_id" value="conferma" />
    <div id="formButtons">
	<button id="salva" name="salva" value="salva" class="button positive">
	    <img src="/images/admin/tick.png" alt="" />Salva ed Esci
	</button>
	<button id="annulla" name="annulla" value="annulla" class="button negative">
	    <img src="/images/admin/cross.png" alt="" />Annulla
	</button>
	
    </div>
</form>
